var userinfo;
$(function () {
    hideNavigator();
    //当前用户的钱包
    var mywallet = null;
    //判断是否有新消息
    var newsflag = server.getCache("newsflag");
    if(newsflag==1){
        $("#newsflag").css("display","block");
    }

    server.getUserInfo(function (e) {

        var userinfo = e;
        $("#membername").text(userinfo.nickname||'');

        $("#headimage").attr("src",userinfo.headimgurl)

        if(!userinfo.memberLevel||userinfo.memberLevel==0){
            $("#memberLevel").text("普通用户")
        }else if(userinfo.memberLevel==1){
            $("#memberLevel").text("尊贵会员")
        }

        server.loadData(".userinfo-username",userinfo);

    });
    //获取当前用户的大师资格申请
    server.req('wechat/teacher/getByMemberId',{},function (e) {
        if(e.code==0){
            var data = e.data;
            if(e.data!=null){
                if(data.status==2){
                    // console.log("show ...")
                    $("#teacher").show();
                }
            }
        }
    });
    //获取当前用户的钱包
    server.req('wechat/memberwallet/getbymemberid',{},function (res) {
        // console.log(res)
        if(res.code==0){
            mywallet = res.data;
            $("#yongjin").text((mywallet&&mywallet.commissionBalance)||0);
        }
    })
    //获取我的订单
    server.req('wechat/order/list',{},function (res) {
        // console.log(res)
        $("#tiwen").text(res.size);
    });
    //获取我的人脉
    // server.req('wechat/fan/myRenmai',{},function (res) {
    //     console.log(res)
    //     $("#renmai").text(res.size);
    // });
    server.req('wechat/member/myconnection',{},function (res) {
        // console.log('我的人脉');
        //     console.log(res)
        if(res.code==0){
            $("#renmai").text(res.data);
        }
        });
    //获取我的关注
    server.req('wechat/fan/myGuanzhu',{},function (res) {
        console.log(res)
        $("#guanzhu").text(res.size);
    });
});
function quickMenu(quickmenu){
    // console.log("quick_menu="+quickmenu);
    if(quickmenu=="apply"){
        server.loadindex('page/teacher/joinapply/joinapply');
        return;
    }else if(quickmenu=="index"){
        // console.log("index")
        server.loadindex('page/teacher/teacherindex/teacherindex');
        return;
    }
};
function orderlist(menu) {
    server.loadindex('page/order/orderlist/orderlist','menu='+menu);
};
//我的钱包
function mywallet() {
    server.loadindex('page/user/mywallet/mywallet');
}
//联系我们
function tocontactus() {
    server.loadindex('page/user/contactus/contactus');
};
//去推广中心
function popularcenter() {
    server.loadindex('page/user/popularcenter/popularcenter');
};
//开通会员vip
function vipbuy() {
    server.loadindex('page/user/vipbuy/vipbuy');
};
//修改会员资料
function memberinfo() {
    server.loadindex('page/user/memberinfoconfig/memberinfoconfig');
}
//我的人脉
function user_myRenmai(){
    server.loadindex('page/user/xiaxian/xiaxian');
}
//我的关注
function guanzhu(){
    server.loadindex('page/user/guanzhu/guanzhu');
}
